package com.welsmann.app.start.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.welsmann.app.start.dao.INewsDAO;
import com.welsmann.app.start.dao.INewsTitleDAO;
import com.welsmann.app.start.dao.INewsTypeDAO;
import com.welsmann.app.start.entity.News;
import com.welsmann.app.start.entity.NewsTitle;
import com.welsmann.app.start.entity.NewsType;
import com.welsmann.app.start.service.BaseService;
import com.welsmann.app.start.service.INewsService;

@Service("NewsService")
@Transactional(readOnly = true)
public class NewsService extends BaseService implements INewsService{

	@Resource(name = "NewsTitleDAO")
	private INewsTitleDAO newsTitleDAO;
	
	@Resource(name = "NewsTypeDAO")
	private INewsTypeDAO newsTypeDAO;
	
	@Resource(name = "NewsDAO")
	private INewsDAO newsDAO;
	
	@Override
	public List<NewsTitle> getTopNews() {
		return newsTitleDAO.getTop();
	}

	@Override
	public List<NewsType> getAllType() {
		return newsTypeDAO.getAll();
	}

	@Override
	public List<NewsTitle> getTitleListByTypeId(String typeId) {
		return newsTitleDAO.getTitleListByTypeId(typeId);
	}

	@Override
	public News getNewsById(String nId) {
		return newsDAO.getNewsById(nId);
	}

	@Override
	public NewsTitle getNewsTitleById(String nId) {
		return newsTitleDAO.find(nId);
	}
}
